package com.haier.uos.weather.data.controller;

import com.haier.uos.weather.data.service.IWeatherDataService;
import com.haier.uos.weather.data.vo.WeatherResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(value = "/weather")
public class WeatherDataController {
    @Autowired
    private IWeatherDataService weatherDataService;

    @GetMapping(value = "/cityId/{cityId}")
    public WeatherResponse getWeatherByCityId(@PathVariable String cityId) {
        return weatherDataService.getByCityId(cityId);
    }

    @GetMapping(value = "/cityName/{cityName}")
    public WeatherResponse getWeatherByCityName(@PathVariable String cityName) {
        return weatherDataService.getByCityName(cityName);
    }
}
